package cn.gjculture.shopping.api.dao;

import cn.gjculture.shopping.api.entity.Address;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface AddressDao {
    @Insert("insert into address(customerId,addressId,provinceId,cityId,areaId,detailAddress,status,receiver,phone) " +
            "values(#{customerId},#{addressId},#{provinceId},#{cityId},#{areaId},#{detailAddress},#{status},#{receiver},#{phone})")
    int insert(Address address);

    @Select("select * from address")
    List<Address> query();

    @Select("select * from address where addressId=#{addressId}")
    Address queryById(String addressId);

    @Select("select * from address where customerId=#{customerId}")
    List<Address> queryByCustomerId(String customerId);

    @Select("select count(customerId) from address")
    int count(String customerId);

    @Update("update address set status=#{status} where customerId=#{customerId}")
    int updateStatusByCustomer(Address address);

    @Update("update address set status=#{status} where addressId=#{addressId}")
    int updateStatusById(Address address);
}
